﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Gmis.BLL;
namespace Gmis.Web.Manage.Village
{
    public partial class ColumnList : Gmis.Web.BasePage.PageBase
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                IniteData();
            }
            


        }

        private void IniteData()
        {
            try
            {
                string columnTree = "";
                //throw new NotImplementedException();
                Gmis.BLL.Village village = new BLL.Village();
                List<Gmis.Model.Village> listVillage = village.GetModelList("");
                Gmis.BLL.Column column = new BLL.Column();
                foreach (Gmis.Model.Village v in listVillage)
                {
                    columnTree += "<li><a href=\"Village/ColumnAdd.aspx?VillageId=" + v.sId + "\" target=\"ajax\" rel=\"jbsxBox1\" >" + v.sName + "</a>" + System.Environment.NewLine;
                    List<Gmis.Model.Column> listColumn = column.GetModelList(" svillage='" + v.sId + "' and sparent=''");

                    if (listColumn.Count > 0)
                    {
                        columnTree += "<ul>";
                    }
                    foreach (Gmis.Model.Column c in listColumn)
                    {
                        //此处应是一个tree 现在只是第一级，即sparent=''
                        columnTree += "<li><a href=\"Village/ColumnEdit.aspx?VillageId=" + v.sId + "&ColumnId=" + c.sId + "\" target=\"ajax\" rel=\"jbsxBox1\">" + c.sName + "</a> </li>";
                    }
                    if (listColumn.Count > 0)
                    {
                        columnTree += "</ul>";
                    }

                }
                if (columnTree.Length > 0)
                {
                    UlColumn.InnerHtml = columnTree;
                }
            }
            catch
            { }
        }
    }
}